﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MCSharp.Hooks
{
    public static class HookMgr {
        private static Dictionary<HookType, SortedList<int, Hook>> hooks = new Dictionary<HookType, SortedList<int, Hook>>();

        public static void RegisterHook(Hook h) {
            HookType type = h.getType();
            int priority = h.GetPriority();
            hooks[type].Add(priority, h);
        }

        public static void ExecuteHooks(HookType type, params object[] parameters) {
            var hooksOfType = hooks[type];
            foreach (KeyValuePair<int, Hook> pair in hooksOfType)
                pair.Value.Execute(parameters);
        }
    }
}
